package com.web.kdl.controller.report;

import com.web.kdl.common.result.CommonResult;
import com.web.kdl.component.WebSocketService;
import com.web.kdl.pojo.Vo.EnergyDataVo;
import com.web.kdl.pojo.Vo.flywheel.FLywheelStatusVo;
import com.web.kdl.pojo.Vo.site.*;
import com.web.kdl.pojo.dto.FlywheelMainDto;
import com.web.kdl.pojo.dto.SiteDto;
import com.web.kdl.service.report.Report1Service;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 站点接口
 */
@RestController
@Slf4j
//@RequestMapping("/site")
public class Report1Controller {
    // 查询站点详细信息
    @Autowired
    private Report1Service report1Service;

    // 地图站点页面信息
    @PostMapping("/getSiteInfoForMap")
    public CommonResult getSiteInfoForMap(@Validated @RequestBody SiteDto dto){
        log.info("开始调用：{}/getSiteInfoForMap",dto.getSiteName());
        return report1Service.getSiteInfoForMap(dto);
    }
    // 站点页面 基本信息
    @MessageMapping("{siteName}/getSiteBaseInfo")
    @SendTo("/response/{siteName}/getSiteBaseInfo")
    @PostMapping("/getSiteBaseInfo")
    public CommonResult getSiteBaseInfo(@Validated SiteDto dto){
        log.info("开始调用：{}/getSiteBaseInfo",dto.getSiteName());
        return report1Service.getSiteBaseInfo(dto);
    }

    // 获取站点做大功率 近7天 包括当日=>修改为获取站点实时功率 近一天 TODO
    @PostMapping("/getSiteMaxPower")
    @MessageMapping("{siteName}/getSiteMaxPower")
    @SendTo("/response/{siteName}/getSiteMaxPower")
    public CommonResult getSiteMaxPower(@Validated SiteDto dto) {
        log.info("开始调用：{}/getSiteMaxPower",dto.getSiteName());
       return report1Service.getRecent7DaysDailyMaxPower(dto);
    }

    // 站点详细信息 TODO 显示问题映射？
    @PostMapping("/getSiteDetail")
    @MessageMapping("{siteName}/getSiteDetail")
    @SendTo("/response/{siteName}/getSiteDetail")
    public CommonResult getSiteDetail(@Validated SiteDto dto) {
        log.info("开始调用：{}/getSiteDetail",dto.getSiteName());
        return report1Service.getAllDetailSite(dto);
    }

    // 站点电量
    @PostMapping("/getSiteEle")
    @MessageMapping("{siteName}/getSiteEle")
    @SendTo("/response/{siteName}/getSiteEle")
    public CommonResult<List<EnergyDataVo>> getSiteEle(@Validated SiteDto dto) {
        log.info("开始调用：{}/getSiteEle",dto.getSiteName());
        return report1Service.getAllFlywheelEleCount(dto);
    }

    //     站点监控信息 -集合列表形式-(4个飞轮)
    @PostMapping("/getSiteMon")
    @MessageMapping("{siteName}/getSiteMon")
    @SendTo("/response/{siteName}/getSiteMon")
    public CommonResult<List<SiteMonVo>> getSiteMon(@Validated SiteDto dto) {
        log.info("开始调用：{}/getSiteMon",dto.getSiteName());
        return report1Service.getSiteMonMsg(dto);
    }

    //获取站点 飞轮工作状态统计
    @PostMapping("/getSiteFlyWheelStatus")
    @MessageMapping("{siteName}/getSiteFlyWheelStatus")
    @SendTo("/response/{siteName}/getSiteFlyWheelStatus")
    public CommonResult getSiteFlyWheelStatus(@Validated SiteDto dto) {
        log.info("开始调用：{}/getSiteFlyWheelStatus",dto.getSiteName());
        return report1Service.getAllFlywheelStatus(dto);
    }

}
